<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
	<head>
		<title>添加选校</title>
		<script type="text/javascript">		
			$(document).ready(function(){
				$("#materialInfoForm").validationEngine({
					promptPosition : "topLeft",
					ajaxFormValidation: true,
					onAjaxFormComplete: function (status, form, json, options){
						if (json === 1) {
							art.dialog.tips("<label class='success'>添加成功！</label>", 1);
			        		$("button").attr("disabled", true);
							window.parent.location.reload();
						}else{
							art.dialog.tips("<label class='error'>添加失败，请刷新页面重试！</label>", 1);
						}
					}
				});

				$("#schoolName").autocomplete("${ctx}/querySchoolName.html",{
					minChars: 0,
					width: 188,
					mustMatch: false,
					matchContains: true,
					extraParams:{
						keyword:function(){
							return $.trim($("#schoolName").val());
						}
					},
			        parse: function(data) {
			            return $.map(eval(data), function(row) {
			                return {
			                    data: row,
			                    value: row.name,
			                    result: row.name
			                }
			            });
			        },
			        formatItem: function(row, i, max) {
			        	return row.name + "( " + row.country + " )";
			        }
		    	}).result(function(event, row, formatted) {
		    		$("#schoolId").val(row.id);
	   			});


				$("#applyMajorName").autocomplete("${ctx}/queryMajorName.html",{
					minChars: 0,
					width: 188,
					mustMatch: false,
					matchContains: true,
					extraParams:{
						keyword:function(){
							return $.trim($("#applyMajorName").val());
						}
					},
			        parse: function(data) {
			            return $.map(eval(data), function(row) {
			                return {
			                    data: row,
			                    value: row.name,
			                    result: row.name
			                }
			            });
			        },
			        formatItem: function(row, i, max) {
			        	return row.name;
			        }
		    	}).result(function(event, row, formatted) {
		    		$("#applyMajorId").val(row.id);
	   			});
			});

			function changeGreOrSat(obj){
				if($(obj).val() == 1){
					$("#satId").show();
					$("#greId").hide();
				}else{
					$("#greId").show();
					$("#satId").hide();
				}
			}
		</script>
	</head>
	<body>
		<div class="container_16">
			<div class="grid_16">
				<div class="content_top">
					<span>添加选校</span>
				</div>
				<div class="content_bottom">
					<form id="materialInfoForm" action="${ctx }/saveMaterialInfo.html" method="post">
						<input type="hidden" id="vipServiceId" name="vipServiceId" value="${param.vipServiceId }" />
						<table cellpadding="0" cellspacing="0" style="margin-left: 60px; width: 350px;">
							<tr>
								<td>
									<label>
										选择学校：
									</label>
								</td>
								<td>
									<input type="text" id="schoolName" name="schoolName" class="validate[required] input" />
									<input type="hidden" id="schoolId" name="schoolId" />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										选择学位：
									</label>
								</td>
								<td>
									<select id="applyDegree" name="applyDegree" class="validate[required] input_100" onchange="changeGreOrSat(this)">
										<option value="1">学士</option>
										<option value="2">硕士</option>
										<option value="3">博士</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										选择专业：
									</label>
								</td>
								<td>
									<input type="text" id="applyMajorName" name="applyMajorName" class="validate[required] input" />
									<input type="hidden" id="applyMajorId" name="applyMajorId" />
								</td>
							</tr>
						</table>
						<div class="content_top" style="border-left: none;border-right: none;">
							<span>申请要求</span>
						</div>
						<table cellpadding="0" cellspacing="0" style="margin-left: 60px; width: 350px;">
							<tr>
								<td>
									<label>
										TOEFL最低分数：
									</label>
								</td>
								<td>
									<input type="text" id="toefl" name="materialInfo.toefl" class="input_100" />
								</td>
							</tr>
							<tr id="greId" style="display: none;">
								<td>
									<label>
										GRE最低分数：
									</label>
								</td>
								<td>
									<input type="text" id="gre" name="materialInfo.gre" class="input_100" />
								</td>
							</tr>
							<tr id="satId">
								<td>
									<label>
										SAT最低分数：
									</label>
								</td>
								<td>
									<input type="text" id="sat" name="materialInfo.sat" class="input_100" />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										个人陈述：
									</label>
								</td>
								<td>
									<input type="text" id="ps" name="materialInfo.ps" class="input_100" />
									<label>篇</label>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										简历：
									</label>
								</td>
								<td>
									<input type="text" id="cv" name="materialInfo.cv" class="input_100" />
									<label>篇</label>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										推荐信：
									</label>
								</td>
								<td>
									<input type="text" id="rl" name="materialInfo.rl" class="input_100" />
									<label>篇</label>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										论文：
									</label>
								</td>
								<td>
									<input type="text" id="eassy" name="materialInfo.essay" class="input_100" />
									<label>篇</label>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										申请截止日期：
									</label>
								</td>
								<td>
									<input type="text" id="applyEndTime" name="materialInfo.applyEndTime" class="validate[required,custom[date]] input" />
									<script>										        
										datePickerController.createDatePicker({ 
										    formElements:{"applyEndTime":"%Y-%m-%d"}
									    });
								    </script>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										申请提交网址：
									</label>
								</td>
								<td>
									<input type="text" id="applyUrl" name="materialInfo.applyUrl" class="input" />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										申请费用：
									</label>
								</td>
								<td>
									<input type="text" id="applyCost" name="materialInfo.applyCost" class="input_100" />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										材料寄送日期：
									</label>
								</td>
								<td>
									<input type="text" id="sendTime" name="materialInfo.sendTime" class="validate[custom[date]] input" />
									<script>										        
										datePickerController.createDatePicker({ 
										    formElements:{"sendTime":"%Y-%m-%d"}
									    });
								    </script>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										材料寄送地址：
									</label>
								</td>
								<td>
									<input type="text" id="sendAddress" name="materialInfo.sendAddress" class="input" />
								</td>
							</tr>
							<tr>
								<td>
									&nbsp;
								</td>
								<td>
									<label class="btn">
										<input type="submit" value="添加" />
									</label>
								</td>
							</tr>
						</table>
					</form>
				</div>
			</div>		
		</div>
	</body>
</html>
